<template>
  <div class="statistic-tabs-container">
    <div v-for="(item, index) in tabsList"
         :key="item.key"
         :class="['statistic-item', { 'statistic-item-active': value == item.key }]"
         @click="$emit('handleChange', item.key)">
      <p :class="['item-text', {'item-text-hide-value': item.hideValue}]">{{ item.title }}</p>
      <p class="statistic-count">
        <span v-if="!item.hideValue"
              class="statistic-value"
              :style="{ color: item.color ? item.color : undefined }">{{ item.value || 0 }}</span>
      </p>
      <div class="right-top-arrow"></div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'StatisticTabsHeader',
    props: {
      value: {
        type: String,
        default: ''
      },
      tabsList: {
        type: Array,
        default: () => []
      }
    }
  };
</script>

<style lang="scss" scoped>
  .statistic-tabs-container {
    background-color: #fff;
    margin: 12px 16px 0 16px;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-start;

    .statistic-item {
      position: relative;
      cursor: pointer;
      min-width: 152px;
      height: 30px;
      line-height: 30px;
      color: #333;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border: 1px solid #dadada;
      margin-right: 14px;
      padding: 0px 14px;
      border-radius: 2px;
      &:hover {
        color: #1890ff;
        color: var(--theme-brand6, #1890ff);
        border-color: #1890ff;
        border-color: var(--theme-brand6, #1890ff);
      }

      .item-text {
        text-align: left;
        font-family: PingFangSC-Regular;
        font-weight: 400;
        font-size: 14px;
        text-overflow: ellipsis;
        word-break: keep-all;
        white-space: nowrap;
        overflow: hidden;
        flex: 1 1 auto;
      }
      .item-text-hide-value {
        text-align: center;
      }

      .statistic-value {
        padding-left: 12px;
        font-weight: 600;
        font-size: 16px;
      }
    }

    .statistic-item-active {
      color: #1890ff;
      color: var(--theme-brand6, #1890ff);
      border-color: #1890ff;
      border-color: var(--theme-brand6, #1890ff);
      background: #eef5fe;
      background: var(--theme-brand1, #eef5fe);
    }

    .statistic-item-active .right-top-arrow {
      position: absolute;
      top: 0;
      right: 0;
      border-top: 4px solid #1890ff;
      border-top-color: var(--theme-brand6);
      border-left: 4px solid transparent;
      border-bottom: 4px solid transparent;
      border-right: 4px solid #1890ff;
      border-right-color: var(--theme-brand6);
    }
    p {
      margin-bottom: 0px;
    }
  }
</style>
